#!/bin/bash




#input paramters index
echo "OPTIND starts at $OPTIND"
#get paramters   如果 ： 开头， 输入错误的参数 m 则会提示你 opt_parameter.sh: m
while  getopts ":un:p:g" optname
 do
 case "$optname" in
        "p")
          echo "paramter $optname password is  $OPTARG"
          ;;
        "u")
          echo "paramter $optname username is $OPTARG"
          echo ' u选项被设置了 '
          ;;
        "n")
          echo "paramter $optname username is $OPTARG"
          ;;
        "g")
          echo "paramter $optname username is $OPTARG"
          ;;
        "?")
          echo "Unknown option $OPTARG" #getopts检测到一个无效的选项，opt的值会被设置为 ?
          ;;
        ":")
          echo "No argument value for option $OPTARG"  #   getopts检测到一个后面需要跟参数的选项，后面没有参数，opt的值会被设置为 ：
          ;;
        *)
          # Should not occur
          echo "Unknown error while processing options"
          ;;
 esac
 echo "OPTION is now $OPTIND"
done
echo "OPTION 2 is now $OPTIND"
echo "a1=$1, a2=$2"

shift $((OPTIND -1 ))

echo "a1=$1, a2=$2"


